﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Fluent;
using VisionAppManager.ViewModel;

namespace VisionAppManager
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        public MainWindow()
        {
            // 获取当前进程的名称
            string procName = Process.GetCurrentProcess().ProcessName;

            // 获取同名的进程
            var runningProcesses = Process.GetProcessesByName(procName);

            if (runningProcesses.Length > 1)
            {
                Console.WriteLine("Application is already running.");
                Environment.Exit(0);
            }

            InitializeComponent();
            Closing += (s, e) => ViewModelLocator.Cleanup();
        }
    }
}
